package com.indusfo.spc.controller;

import com.indusfo.spc.pojo.Rule;
import com.indusfo.spc.service.RuleService;
import com.indusfo.spc.vo.JSONObject;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.annotation.Resource;
import java.util.List;

@Controller
@RequestMapping("/service/rule")
public class RuleController {
	
	@Resource
	private RuleService ruleService;


	/**
	 * @Author 熊冰 查询条码
	 * @Date 2020/1/16 14:24
	 */
	@RequestMapping("/queryRule")
	@ResponseBody
	public JSONObject queryRule(Rule rule){
		JSONObject json = ruleService.queryRule(rule);
		return json;
	}
/**
 * @Author 熊冰 新增条码
 * @Date 2020/1/16 14:25
 */
	@RequestMapping("insertRule")
	@ResponseBody
	public JSONObject insertRule(Rule rule){
		JSONObject json = ruleService.insertRule(rule) ;
		return json;
	}

/**
 * @Author 熊冰 修改条码
 * @Date 2020/1/16 14:25
 */
	@RequestMapping("/updateRule")
	@ResponseBody
	public JSONObject updateRule(Rule rule){
		JSONObject json = ruleService.updateRule(rule);
		return json;
	}

	/**
	 * @Author 熊冰 删除
	 * @Date 2019/11/21  13:10
	 *
	 */
	@RequestMapping(value="/deleteRule", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject deleteRule(Integer[] ruleIds, Integer dataState) {
		dataState = 2;
		JSONObject json = ruleService.deleteRule(ruleIds, dataState);
		return json;
	}

	/**
	 * @Author 熊冰 启用/停用
	 * @Date 2019/11/21 13:15
	 *
	 */
	@RequestMapping(value="/definedRule", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject definedRule(Integer[] ruleIds, Integer dataState) {
		JSONObject json = ruleService.deleteRule(ruleIds, dataState);
		return json;
	}

	/**
	 * @Author 熊冰 创建条码
	 * @Date 2020/1/14 14:15
	 */
	@RequestMapping(value="/createRule", method= RequestMethod.POST)
	@ResponseBody
	public JSONObject createRule(Rule rule){
		JSONObject json = ruleService.createRule(rule);
		return json;
	}



//	/**
//	 * 新增
//	 * @param rule
//	 * @return
//	 */
//	@RequestMapping("insertRule")
//	@ResponseBody
//	public JSONObject insertRule(Rule rule){
//		JSONObject json = ruleService.insertRule(rule) ;
//		return json;
//	}
//
//	/**
//	 * 删除
//	 */
//	@RequestMapping("/deleteRule")
//	@ResponseBody
//	public JSONObject deleteRule(Integer[] ids, Integer dataState){
//		dataState = 2;
//		JSONObject json = ruleService.deleteRule(ids,dataState);
//		return json;
//	}
//
//	/**
//	 * 修改
//	 */
//	@RequestMapping("/updateRule")
//	@ResponseBody
//	public JSONObject updateRule(Rule rule){
//		JSONObject json = ruleService.updateRule(rule);
//		return json;
//	}
//
//
//	/**
//	 *
//	 * 查询
//	 * @param rule
//	 * @return
//	 */
//	@RequestMapping("/queryRule")
//	@ResponseBody
//	public JSONObject queryRule(Rule rule){
//		JSONObject json = ruleService.queryRule(rule);
//		return json;
//	}
}
